<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                        <i class="fa  fa-fw fa-reorder"></i>申请配货
                        </li>
                    </ol>
                </div>
            </div>
            <div class="cent">
    <span class="bg" style="position: absolute;width: 100%;height: 100%;background: black;
    opacity: 0.3;z-index: 10;padding: 0;display: none"></span>
            <div class="column">
                <div class="text-center"><h4>申请记录</h4></div>
                <span style="margin-left:40px;">所在部门：</span>
    <select style="width:80px;height:30px;" name="department_id" id="department">
<option value="0">全部</option>
    <?foreach($departmentinfo as $v ){?> <option value="<?=$v['id']?>" <?= $department_id==$v['id']?'selected':'';?> ><?=$v['introduce']?></option><?}?>
</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            
<span style="margin-left:40px;">配送状态：</span>
    <select style="width:80px;height:30px;" name="statusid" id="status">
<option value="0">全部</option>
<option value="1" <?= $statusid==1? 'selected':''; ?> >已提交</option>
<option value="2" <?= $statusid==2? 'selected':''; ?> >采购中</option>
<option value="3"<?= $statusid==3? 'selected':''; ?> >配送中</option>
<option value="3"<?= $statusid==5? 'selected':''; ?> >已收货</option>
</select>

                <a class="addBtn btn btn-blue" id="search" style="margin-left:50px" href="#" onclick="searchinfo()">搜索</a>
               <!-- <a class="addBtn btn btn-blue" style="margin-left:400px;" href="/admin_apply/">新增</a>-->
                </form>
            </div>
            <div class="panel-body text-center">
                <table class="table table-hover" id="table_list">
                    <thead>
                        <tr>
                            <td>编号</td>
                            <td>部门</td>
                            <td>申请物品</td>
                            <td>申请数量</td>
                            <td>申请时间</td>
                            <td>操作人员</td>
                            <td>状态</td>
                            <td>备注</td>
                        </tr>
                    </thead>
                    <?foreach($listinfo as $tRow){?>
                    <tr>
                        <td><?=$tRow['apply_id']?></td>
                        <td><?=$tRow['introduce']?></td>
                        <td><?=$tRow['apply_name']?></td>
                        <td><?=$tRow['apply_num']?><?=$tRow['apply_com']?></td>
                        <td><?=$tRow['apply_time']?></td>
                        <td><?=$tRow['name']?></td>
                        <td><?if($tRow['sta_id']==1){echo '已提交';}elseif($tRow['sta_id']==3){echo "配送中";}elseif($tRow['sta_id']=='4'){?><button id="cg" onclick="purchase(<?=$tRow['apply_id']?>)">确认收货</button><?}elseif($tRow['sta_id']=='5'){echo $tRow['sta_name'];}else{echo '采购中';}?></td>

                        <td><?=$tRow['apply_bei']?></td>
                    </tr>
                    <?}?>
                </table>
                <?=$pageinfo?>
            </div>
        </div>
        <div class="subviews">
            <div class="subviews-container"></div>
        </div>
    </div>
    <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
<script>
   function purchase(appid){
           
           $.ajax({
            type:'post',
            url:'/admin_apply/updatestatus',
            data:{id:appid},
            success:function(msg){
                    if(msg.status==1){
                            alert('已修改')
                            window.location.reload();
                    }else{
                        alert(msg.msg)
                    }
            }
        }) 
   }
   function searchinfo(){
              var statusid = $('#status').val();
              var department = $('#department').val();
             location.href="/admin_apply/list?statusid="+statusid+"&department_id="+department
    }
</script>
<script>
    var color="#eeeeee";
    $("#table_list tr:odd td").css("background-color",color);  //改变偶数行背景色
    /* 把背景色保存到属性中 */
    $("#table_list tr:odd").attr("bg",color);
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
